package MapHomeWork.thirdth;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class test {
    public static void main(String[] args) {
        List<Student> studentList=new ArrayList<>();
        studentList.add(new Student("张三",20,90.0f));
        studentList.add(new Student("李四",22,90.0f));
        studentList.add(new Student("王五",20,95.0f));
        studentList.add(new Student("赵六",22,100.0f));
        studentList.add(new Student("田七",26,87.0f));

        Collections.sort(studentList, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                float M=o1.getScore()-o2.getScore();
                return (int) M;
            }
        });

        for (Student s: studentList) {
            System.out.println(s);
        }
    }
}
